import { defineStore } from "pinia";

// 第一个参数必须是全局唯一
export const useUserStore = defineStore("user", {
  state: () => ({
    userInfo: {},
    token: "",
  }),
  getters: {
    getToken: state => state.token,
    getUserInfo: state => state.userInfo,
  },
  actions: {
    setToken(token) {
      this.token = token;
    },
    setUserInfo(userInfo) {
      this.userInfo = userInfo;
    },
  },
  persist: {
    key: 'nestjs-panghu'
  }
});
